<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>活动照</title>
	<link rel="stylesheet" href="css/MomPhoto.css" />
	<link rel="stylesheet" href="css/upWindow.css" />
	<link rel="stylesheet" href="css/style.css" />
	<link rel="stylesheet" href="css/TV.css" />
	<link rel="stylesheet" href="css/base.css" />
	<link rel="stylesheet" href="css/MomPhotoDetail.css" />
	<script type="text/javascript" src="js/dom/jquery.js"></script>
	<script type="text/javascript" src="js/register.js"></script>
	<script type="text/javascript" src="js/topPublic.js"></script>
	<script type="text/javascript" src="bootstrap/js/jquery1.11.3.js"></script>
</head>

<body>
	<script type="text/javascript" src="js/header.js"></script>
	<div class="banner-img">
		<img src="img/img_02.jpg" />
	</div>
	<div class="Mom-photo">
		<div class="Mbox">
			<p class="Mom-show">
				<span class="Ms-span1">活动照片</span>
				<span class="Ms-span2"> / Activity Photos</span>
				<span class="Ms-span3"></span>
			</p>
			<ul style="margin-top: 48px;margin-bottom:100px;overflow: hidden;width:1200px;" id="mom_list">
				
			</ul>
		</div>
	</div>
	<div class="add-comments">
		<div class="word-limit">
			<span id="counter" class="span1">0</span>
			<span>/</span>
			<span>300</span>
		</div>
		<textarea maxlength="300" class="mes" id="status" name="status" rows="6" cols="40"  placeholder="看到槽点，不吐不快！别憋着，马上大声说出来吧！"></textarea>
		<span class="addcomm" onclick="publishcomm()">发表评论</span>
		<ul class="all-comments">
			<li class="comm-list no-pad">
				<span class="comm-list-title2 comm-list-title-che" id="one2" onclick="submitcomm('a129d72574344578b7291cff1d72e542')">全部评论<span class="totalRowNumber totalRowNumber1"></span></span>
				<span class="comm-list-title2" id="two2" onclick="submitmycomm('a129d72574344578b7291cff1d72e542')">我的评论<span class="totalRowNumber totalRowNumber2"></span></span>
			</li>
			<ul class="all-comments-one" id="all-comments-one2">
				<div class="commbox"></div>
			</ul>
		</ul>
	</div>
	<input type="hidden" value="tv" id="navid" />
	<script type="text/javascript" src="js/footer.js"></script>
	<script type="text/javascript" src="js/banner.js"></script>
	<script>
	$(function() {
		demo();
		submitcomm('a129d72574344578b7291cff1d72e542');
	});

	function demo(curr) {
		var key = $("#key").val();

		$.ajax({
			url:'/baby/usaBabyMonth/queryMenuUsaBabyMonth',
			data:{
				menutype : 'a129d72574344578b7291cff1d72e542'
			},
			type: 'post',
			cache: false,
			dataType: 'json',
			success: function(data) {
				console.log(data);
				if(data.code == "2000") {
					var datalist = data.data;
					//拼页面
					var htmlstr = '';
					for(var i = 0; i < datalist.length; i++) {
						var obj = datalist[i].imgData[0]; //获取单个数据对象
						var introduce = datalist[i].introduce;
						var title = datalist[i].title;
						var createTime = datalist[i].createTime;
						//拼页面
						var comurl = "activityPhotoDetail.html?sid=" + datalist[i].sid;
						htmlstr += '<li class="M-group"><a href="' + comurl + '"><img src="' + obj.realPicUrl + '@!cpr" /></a>' +
							'<span class="span1">' + title + '</span>' + introduce +'<p>'
							 + createTime + '</p></li>'						
					}
					document.getElementById("mom_list").innerHTML = htmlstr

				} else if(data.code == "5001") {
					alert(data.message);

				}
			},
			error: function() {
				// view("异常！");  
				//alert("异常！");
			}
		});
	};
//发表评论
	function publishcomm(){
		var commentMsg = $("#status").val();
		if(commentMsg==''){
	    	alert("请填写评论内容");
	      	return 
	    }
		var sid=$("#sid").val();
		$.ajax({
			url: '/baby/comment/addComment',
			data: {
				contentId:'a129d72574344578b7291cff1d72e542',
				commentMsg:commentMsg
			},
			type: 'post',
			cache: false,
			dataType: 'json',
			success: function(data) {
//				console.log(data);
				if(data.code == "2000"){
					alert(data.message);  //评论成功提示语
					$("#status").val("");
					submitcomm('a129d72574344578b7291cff1d72e542');
				}else if(data.code == "5001"){
					$('.theme-popover-mask').show();
					$('.theme-popover-mask').height($(document).height());
					$('.theme-popover').slideDown(200);
				}
			}
		})
	}
////////所有评论////////
	function submitcomm(id){
		//var sid = $("#sid").val();
		$.ajax({
			url: '/baby/comment/queryComment',
			data: {
				key : id
			},
			type: 'post',
			cache: false,
			dataType: 'json',
			success: function(data) {
				if(data.code == "2000") {
//					console.log(data)
					$(".commbox").text('');
					$(".totalRowNumber1").text('');
					$(".totalRowNumber2").text('');
					var datalist = data.data.dataList;
					var userName = '';
					var commentMsg = '';
					var str = '';
					var time = '';
					var totalRowNumber = '&nbsp;&nbsp;('+ data.data.totalRowNumber +')&nbsp;&nbsp;';
					for(i = 0; i < datalist.length; i++) {
						var img = datalist[i].user.realPicUrl;
						commentMsg = datalist[i].commentMsg;
						userName = datalist[i].user.userName;
						time = datalist[i].commentCreateTime;
						str = 	'<li class="comm-list">'+	
									'<img src="'+ img+'" />'+
									'<div class="comm-list-text">'+
										'<span style="color: #656565;font-weight: bold;">'+userName+'</span>'+
										'<span style="color: #b7b7b7;margin-left: 10px;">'+time+'</span>'+
										'<p class="word-break" id="commentMsg" style="color: #656565;line-height: 20px;margin-top: 8px;">'+commentMsg+'</p>'+
									'</div>'+
								'</li>';
						$(".commbox").append(str);
					}
					$(".totalRowNumber1").append(totalRowNumber);
					console.log(data);
				}
			},
			error: function(data) {
				console.log("服务请求的人太多"+data);
			}
		})
	}
////////我的评论////////
	function submitmycomm(sid){
		$.ajax({
			url: '/baby/comment/getComment',
			data: {
				key : sid
			},
			type: 'post',
			cache: false,
			dataType: 'json',
			success: function(data) {
				if(data.code == "2000") {
					$(".commbox").text('');
					$(".totalRowNumber2").text('');
					$(".totalRowNumber1").text('');
					var datalist = data.data.dataList;
					var userName = '';
					var commentMsg = '';
					var str = '';
					var time = '';
					var totalRowNumber = '&nbsp;&nbsp;('+ data.data.totalRowNumber +')&nbsp;&nbsp;';
					var userId = '';
					var img;
					for(i = 0; i < datalist.length; i++) {
						try{
							var img = datalist[i].user.realPicUrl;
							commentMsg = datalist[i].commentMsg;
							userName = datalist[i].user.userName;
							time = datalist[i].commentCreateTime;
							userId = datalist[i].userId;
							str = 	'<li class="comm-list">'+	
										'<img src="'+ img+'" />'+
										'<div class="comm-list-text">'+
											'<span style="color: #656565;font-weight: bold;">'+userName+'</span>'+
											'<span style="color: #b7b7b7;margin-left: 10px;">'+time+'</span>'+
											'<p class="word-break" id="commentMsg" style="color: #656565;line-height: 20px;margin-top: 8px;">'+commentMsg+'</p>'+
										'</div>'+
									'</li>';
						$(".commbox").append(str);
						}catch(e){
							//TODO handle the exception
						}
					}
					$(".totalRowNumber2").append(totalRowNumber);
					console.log(data);
				}else if(data.code == "5001"){
					$('.theme-popover-mask').show();
					$('.theme-popover-mask').height($(document).height());
					$('.theme-popover').slideDown(200);
				}
			},
			error: function(data) {
				console.log("服务请求的人太多"+data);
			}
		})
	}
	//留言板字数
	document.getElementById("status").addEventListener('input',function(e){
		var len = document.getElementById("status").value.length;
		document.getElementById("counter").innerHTML = len
	})
	</script>
</body>

</html>